package cn.hackcloud.concurrency.eda.chat;

import cn.hackcloud.concurrency.eda.AsyncEventDispatcher;

public class UserChatApplication {
    public static void main(String[] args) {
        //定义异步 的Router
        final AsyncEventDispatcher dispatcher = new AsyncEventDispatcher();
        //为Router注册Channel和Event之间的关系
        dispatcher.registerChannel(UserOnlineEvent.class, new UserOnlineEventChannel());
        dispatcher.registerChannel(UserOfflineEvent.class, new UserOfflineEventChannel());
        dispatcher.registerChannel(UserChatEvent.class, new UserChatEventChannel());
        //启动三个登录聊天室的User
        new UserChatThread(new User("laishifu"), dispatcher).start();
        new UserChatThread(new User("kangshifu"), dispatcher).start();
        new UserChatThread(new User("xieshifu"), dispatcher).start();

    }
}
